<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>

  /*单向链表 : 节点的类型 :
  * 值
  * next
  * */

  class Node {
    constructor(val) {
      this.val = val;
      this.next = null;// 后继
    }
  }

  let n1 = new Node(10);
  let n2 = new Node(12);
  let n3 = new Node(14);
  n1.next = n2;
  n2.next = n3; // n1 n2 n3 就组成一个链表

  // 打印的是什么
  console.log(n1);

  // 计算链表里面的最大值
  let max = 0;
  let n = n1;
  while (n) {
    if (max < n.val) {
      max = n.val;
    }
    n = n.next;
  }
  console.log(max);

  // 打印链表所有的值 变成字符串用,隔开
  n = n1;
  let str = '';
  while (n) {
    str += n.val;
    if (n.next) {
      str += ','
    }
    n = n.next;
  }
  console.log(str);

  // index 找到对应的元素 0 n1 1:n2  3:n3
  let index = 3;

  //  插入




</script>
</body>
</html>
